/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anism.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author tgqm5519
 */
@Entity
@Table(name = "request_history")
@SequenceGenerator(name = "seq_pk_history", sequenceName = "seq_pk_history", allocationSize = 1)
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RequestHistory.findAll", query = "SELECT r FROM RequestHistory r"),
    @NamedQuery(name = "RequestHistory.findById", query = "SELECT r FROM RequestHistory r WHERE r.id = :id"),
    @NamedQuery(name = "RequestHistory.findByStatus", query = "SELECT r FROM RequestHistory r WHERE r.status = :status"),
    @NamedQuery(name = "RequestHistory.findByDate", query = "SELECT r FROM RequestHistory r WHERE r.date = :date"),
    @NamedQuery(name = "RequestHistory.findByComment", query = "SELECT r FROM RequestHistory r WHERE r.comment = :comment")})
public class RequestHistory implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "seq_pk_history")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 128)
    @Column(name = "status", nullable = false, length = 128)
    private String status;
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Size(max = 2147483647)
    @Column(name = "comment", length = 2147483647)
    private String comment;
    @JoinColumn(name = "request", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private HolidayRequest request;

    public RequestHistory() {
    }

    public RequestHistory(Integer id) {
        this.id = id;
    }

    public RequestHistory(Integer id, String status) {
        this.id = id;
        this.status = status;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public HolidayRequest getRequest() {
        return request;
    }

    public void setRequest(HolidayRequest request) {
        this.request = request;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RequestHistory)) {
            return false;
        }
        RequestHistory other = (RequestHistory) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.anism.entity.RequestHistory[ id=" + id + " ]";
    }
}
